package com.bgs.travelapp.order.controller;

import com.bgs.travelapp.order.entity.ScenicOrderEntity;
import com.bgs.travelapp.order.service.ScenicOrdersService;
import com.bgs.travelapp.page.PageRequest;
import com.bgs.travelapp.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 景区门票订单展示
 *
 */
@RestController
@CrossOrigin
@RequestMapping("/orders/ScenicOrders")
public class ScenicOrderController {
    @Autowired
    ScenicOrdersService scenicOrdersService;

    /**
     * 获取该订单的购票人（前台展示）
     * lzy 2022-8-23 10点15分
     * @param sOId
     * @return
     */
    @GetMapping("getUserBindsListByOrderId")
    public CommonResult getUserBindsListByOrderId(Integer sOId){
        return scenicOrdersService.getUserBindsListByOrderId(sOId);
    }

    /**
     * 根据Id获取订单号（前台展示）
     * lzy 2022-8-23 19点24分
     * @param id
     * @return
     */
    @GetMapping("/getScenicOrderById")
    public CommonResult getScenicOrderById (Integer id) {
        return scenicOrdersService.getScenicOrderById(id);
    }

    /**
     * 获取订单状态列表（前台展示）
     * lzy 2022-8-23 11点33分
     * @return
     */
    @GetMapping("/getOrderStatusList")
    public CommonResult getOrderStatusList(){
        return scenicOrdersService.getOrderStatusList();
    }

    /**
     * 分页全查景区景点订单信息（前端管理展示景点订单信息）
     * fys 2022年8月4日11:02:47
     * lzy 2022-8-23 11点13分
     * @param pageRequest
     * @param loginName
     * @param orderStatus
     * @return
     */
    @RequestMapping("/getScenicOredr")
    public CommonResult getScenicOredr(PageRequest pageRequest,String loginName,Integer orderStatus){
        return CommonResult.ok(scenicOrdersService.getScenicOredr(pageRequest,loginName,orderStatus));
    }

    /**
     * 分页模糊查询景区景点订单信息（后端管理展示）
     * fys 2022年8月16日14:52:47
     * @param pageRequest
     * @param loginName
     * @return
     */
    @RequestMapping("/getScenicOredrByPage")
    public CommonResult getScenicOredrByPage(PageRequest pageRequest,String loginName){
        return CommonResult.ok(scenicOrdersService.getScenicOrderByPage(pageRequest, loginName));
    }

    /**
     * 后端新增订单
     * fys 2022.8.17 15:55
     * @param scenicOrderEntity
     * @return
     */
    @RequestMapping("/saveScenicOrder")
    public CommonResult saveScenicOrder(ScenicOrderEntity scenicOrderEntity){
        return CommonResult.ok(scenicOrdersService.saveScenicOrder(scenicOrderEntity));
    }
    /**
     * 后端修改订单
     * fys 2022.8.17 15:55
     * @param scenicOrderEntity
     * @return
     */
    @RequestMapping("/updateScenicOrder")
    public CommonResult updateScenicOrder(ScenicOrderEntity scenicOrderEntity){
        return CommonResult.ok(scenicOrdersService.updateScenicOrder(scenicOrderEntity));
    }
    /**
     * 删除订单（后端）（del永久删除）
     * @param id
     * @return
     */
    @DeleteMapping("/delScenicOrder")
    public CommonResult delScenicOrder(Integer id) {
        return CommonResult.ok(scenicOrdersService.delScenicOrder(id));
    }
}
